package day02;

import sun.misc.JavaAWTAccess;

public class DataTypeDemo {
    public static void main(String[] args){
        //溢出
        /*
        int c = 2147483647;
        c = c*100;
        System.out.println(c);



        */
        /*
        long a = 10000000000L;//默认为int类型，加L为长整型直接量
        System.out.println(a);
        long c = 1000000000*2*10L;
        System.out.println(c);//200亿
        long d = 100000000*3*10L;
        System.out.println(d);//不是300亿
        long e = 1000000000L*3*10;
        System.out.println(e);//300亿
        */



/*
        double a = 3.14;//默认为double类型
        float b = 3.14F;
        double c = 3.0 , d = 2.9;
        System.out.println(c-d);//有可能会发生舍入误差


 */
        /*
        boolean a = true;
        boolean b = false;
        //布尔型只能赋值为true或false

         */
        /*
        char c1='女';
        char c2='f';
        char c3='6';
        char c4='*';
        //char c5=女;//编译错误，字符型直接量必须放在单引号中
        //char c6='';//编译错误，必学有字符
        //char c7='15';//编译错误，只能有一个字符
        //char c7='女性';//编译错误，只能有一个字符

        char c8='\\';
        System.out.println(c8);

         */

        /*
        int a = 5;
        int b=a;//自动类型转换
        int c = (int)b;//强制类型转换

        long f = 10000000000L;
        int g = (int)f;
        System.out.println(g);//强转时有可能发生溢出

        double h = 25.987;
        int i =(int)h;
        System.out.println(i);//强转时有可能丢失精度

         */

        byte b1 = 5;
        byte b2 = 6;
        byte b3 = (byte)(b1+b2);
//ASCII码 A 65 a 97 0 48
        System.out.println(2+2);//4
        System.out.println(2+'2');//52
        System.out.println('2'+'2');//100 '2'的码50


        /*
        1.变量:
            int a, int b,c;
            int d= 5;
            int e;
            e=5;
            int f= r+10;
            System.out.println(e);
            e = e+10;
         2.8种基本数据类型:
             byte,short,int,long,float,double,boolean,char
             1)int:整型:4个字节,5,25,250,
             2)long:长整型，8个字节，5L，1000000000000L......
             3）double:浮点型,8个字节，3.14,5.0,25.678......
             4）boolean：布尔型,1个字节,true,false
             5）char:字节型,2个字节,'你','y','7','*'
         3.类型间的转换
             1）两种方式:自动,强制
             2）两点规则:
                short s1 = 5；
                short s2 = 6；
                short s3 = (short)(s1+s2);
         */
//            int a = 5;
//            a= a +10;
//            System.out.println(a);
//            double blance = 5000.0;
//            blance = blance+2000;
//            System.out.println(blance);
//            blance = blance-1000;
//            System.out.println(blance);
//
//            double money = 600.0;
//            money = money*0.8;
//            System.out.println(money);





















    }
}
